@ECHO OFF

SETLOCAL
%~d0
CD "%~dp0"

SET ServerAlias="%1%"
IF "%1%"=="" SET ServerAlias=.\SQLEXPRESS

ECHO.
ECHO ===================
ECHO Filters Demo Setup
ECHO ===================
ECHO.

ECHO.
ECHO Dropping and creating the ImageCatalog database...

@CALL SQLCMD -S %ServerAlias% -E -b -i ".\ImageCatalogSchema.sql"
IF ERRORLEVEL 1 GOTO ERROR

ECHO Populating the ImageCatalog database with sample data...

@CALL SQLCMD -S %ServerAlias% -E -b -i ".\ImageCatalogData.sql"
IF ERRORLEVEL 1 GOTO ERROR

ECHO.
ECHO ========================================
ECHO Database created successfully!
ECHO ========================================

GOTO FINISH

:ERROR

ECHO.
ECHO ======================================
ECHO An error occured. 
ECHO Please review messages above.
ECHO ======================================

:FINISH

PAUSE